cmake_minimum_required(VERSION 3.14)

project(opengl_imshow)
include(utils.cmake)

option(use_opencv "Use OpenCV?" OFF)

##########################################
# OpenCV
##########################################
if (use_opencv)
	if (CMAKE_SYSTEM_NAME MATCHES "Windows")
		set(OpenCV_DIR "F:/zhangzhuo/lib/opencv_345/build")
	elseif (CMAKE_SYSTEM_NAME MATCHES "Linux")
		set(OpenCV_DIR "/home/zz/work/opencv_345/build")
	elseif (CMAKE_SYSTEM_NAME MATCHES "Darwin")
		set(OpenCV_DIR "/Users/zz/work/opencv_345/build")
	endif()

	message(STATUS "===== OpenCV_DIR is: ${OpenCV_DIR}")
	find_package(OpenCV REQUIRED)

	message(STATUS "OpenCV library status:")
	message(STATUS "    version: ${OpenCV_VERSION}")
	message(STATUS "    libraries: ${OpenCV_LIBS}")
	message(STATUS "    include path: ${OpenCV_INCLUDE_DIRS}")
	list(APPEND PROJ_LINKER_LIBS ${OpenCV_LIBS})
endif()

include_directories("include")


afq_add_executable(show
    src/main.c
    #src/ex1_hello_window.c
    #src/ex2_hello_triangle.c
    #src/hello.c
    #src/glad.c
)

if (CMAKE_SYSTEM_NAME MATCHES "Windows")
    set(GLFW_DIR "F:/zhangzhuo/dev/glfw-3.3/build/vs2017-x64/install")
    set(GLFW_LIB glfw3)
endif()


if (CMAKE_SYSTEM_NAME MATCHES "Windows")
    target_link_libraries(show glfw3 opengl)
elseif (CMAKE_SYSTEM_NAME MATCHES "Darwin")
    find_package(glfw3 3.3 REQUIRED)
    find_package(GLEW REQUIRED)
    if (GLEW_FOUND)
        message(STATUS "----- GLEW found -----")
        #include_directories(${GLEW_INCLUDE_DIRS})
        #link_libraries(${GLEW_LIBRARIES})
        message(STATUS "----- GLEW_INCLUDE_DIRS: ${GLEW_INCLUDE_DIRS}")
        message(STATUS "----- GLEW_LIBRARIES: ${GLEW_LIBRARIES}")
    endif()
    include_directories(${GLEW_INCLUDE_DIRS})
    target_link_libraries(show glfw "-framework OpenGL" ${GLEW_LIBRARIES})
elseif (CMAKE_SYSTEM_NAME MATCHES "Linux")
    find_package(glfw3 3.3 REQUIRED)
    target_link_libraries(show glfw)
endif()

